<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>用户信息</title>
	<%@ include file="../../include/head.jsp"%>
	<style>
		#uploadPic{cursor: pointer;width: 120px;height: 120px;}
	</style>
</head>
<body>
<div class="admin-content">
	<!-- 内容区域 -->
	<div class="am-g">
		<div class="am-u-sm-12">
			<form class="am-form am-form-horizontal" modelAttribute="user" action="${ctx}/user/saveUserInfo" method="post">
				<input type="hidden" name="id" value="${user.id}" />
				<input type="hidden" id="photo" name="photo" value="${user.photo}" />
				<fieldset>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">用户头像：</label>
						<div class="am-u-sm-8">
							<img id="uploadPic" class="am-img-thumbnail am-circle" src="${pageContext.request.contextPath}/${user.photo}<c:if test="${empty user.photo}">static/3rd-lib/common/img/user.jpg</c:if>" alt="用户头像">
							<input type="file" name="file" id="file" accept="image/png,image/gif,image/jpeg" style="display: none;">
						</div>
						<label class="am-u-sm-1"></label>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">姓名：</label>
						<div class="am-u-sm-8">
							<input type="text" name="name" value="${user.name}">
						</div>
						<label class="am-u-sm-1"></label>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">性别：</label>
						<div class="am-u-sm-5">
							<select name="sex" data="${user.sex}">
								<c:forEach items="${sexs}" var="m">
									<option value="${m}">${m.info}</option>
								</c:forEach>
							</select>
						</div>
						<label class="am-u-sm-4"></label>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">年龄：</label>
						<div class="am-u-sm-8">
							<input type="number" name="age" value="${user.age}" />
						</div>
						<label class="am-u-sm-1"></label>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">身份证：</label>
						<div class="am-u-sm-8">
							<input type="text" name="idCard" value="${user.idCard}" />
						</div>
						<label class="am-u-sm-1"></label>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">邮箱：</label>
						<div class="am-u-sm-8">
							<input type="email" name="email" value="${user.email}">
						</div>
						<label class="am-u-sm-1"></label>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">手机：</label>
						<div class="am-u-sm-8">
							<input type="text" name="mobile" value="${user.mobile}">
						</div>
						<label class="am-u-sm-1"></label>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">电话：</label>
						<div class="am-u-sm-8">
							<input type="tel" name="phone" value="${user.phone}">
						</div>
						<label class="am-u-sm-1"></label>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">备注：</label>
						<div class="am-u-sm-8">
							<textarea rows="5" name="remarks">${user.remarks}</textarea>
						</div>
						<label class="am-u-sm-1"></label>
					</div>
					<div class="am-form-group">
						<div class="am-u-sm-9 am-u-sm-offset-3">
							<button type="submit" class="am-btn am-btn-primary">保 存</button></p>
						</div>
					</div>
				</fieldset>
			</form>
		</div>
	</div>
</div>
<%@ include file="../../include/bottom.jsp"%>
<script type="text/javascript" src="${ctxStatic}/3rd-lib/common/js/ajaxfileupload.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		var msg = '${msg}';
		if(msg!=''){
			iuMsg(msg);
		}
		initSelectValue(true);//初始化下拉框的值
	});
</script>
<script type="text/javascript">
	$(document).ready(function() {
		var ctx = "${pageContext.request.contextPath}";
		$("#uploadPic").click(function(){
			$("#file").click();
		});
		$("#file").change(function(){
			$.ajaxFileUpload({
				url: '${ctx}/upload/local',
				type: 'post',
				secureuri: false,
				fileElementId: 'file',
				dataType: 'text',
				success: function (data, status){
					data = JSON.parse(delHtmlTag(data));
					if(data.ret==1){
						$("#uploadPic").attr("src",ctx+'/'+data.data);
						$("#photo").val(data.data);
					}else{
						iuMsg(data.msg);
					}
				},
				error: function (data, status, e){
					iuMsg("上传失败");
				}
			});
		});
	});
</script>
</body>
</html>